using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cocos2d;

namespace CampaignWP7
{
    enum SPWolfType
    {
        SPWOLF_TURBO = 0,
        SPWOLF_SHIELD,

        SPWOLF_NUM,
    }
    class SpicialWolfFactory
    {
        static public Wolf CreateSpicalWolf(SPWolfType type)
        {
            Wolf wolf = null;
            switch (type)
            {
                case SPWolfType.SPWOLF_TURBO:
                    wolf = new SpicialWolf_Turbo(1);
                    break;
                case SPWolfType.SPWOLF_SHIELD:
                    wolf = new SpicialWolf_Shield(1);
                    break;
            }
            return wolf;
        }
    }
    class SpicialWolf_Turbo : Wolf
    {
        public float turbofactor = 2.0f;
        public SpicialWolf_Turbo(int balloonNum)
            : base(balloonNum)
        {
            WalkSpeed *= turbofactor;
        }
        public override void update(float dt)
        {
            base.update(dt);
        }
    }

    class SpicialWolf_Shield : Wolf
    {
        public Shield m_Shield;
        public override Shield GetShield() { return m_Shield; }
        public SpicialWolf_Shield(int balloonNum)
            : base(balloonNum)
        {
            m_Shield = new Shield();
            m_Shield.visible = false;
        }

        public override void update(float dt)
        {
            if (m_Shield.State == Shield.ShieldState.ShieldState_Hold)
            {
                CCPoint pos = new CCPoint(position.x - width * 0.5f, position.y - height*0.2f);
                m_Shield.MoveTo(pos);
            }
            base.update(dt);
        }

        public override void PlayFloatAnimation()
        {
            m_Shield.visible = true;
            m_Shield.holdShield();
            base.PlayFloatAnimation();
        }

        public override void PlayFallAnimation()
        {
            m_Shield.visible = false;
            base.PlayFallAnimation();
            RemoveShield();
        }

        public override void PlayWalkAnimation()
        {
            m_Shield.visible = false;
            base.PlayWalkAnimation();
        }

        public override void PlayMoveToBuilding(float time, CCPoint pos)
        {
            base.PlayMoveToBuilding(time, pos);
            m_Shield.visible = false;
            RemoveShield();
        }

        private void RemoveShield()
        {
            if (m_Shield != null)
            {
                ResDef.g_ShieldBatchNode.removeChild(m_Shield, true);
            }
        }
    }

    //class SpicialWolf_Friend : Wolf
    //{
    //}
}
